package com.hmkj.core.mapper.userIdentify;

import com.hmkj.common.baseMapper.GenericMapper;
import com.hmkj.core.model.user.UserIdentifyModel;
import com.hmkj.core.po.userIdentify.UserIdentify;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 用户认证相关Dao接口<br>
 *
 * @author lizhijie
 * @date 2018-07-04 04:54:55
 */
public interface UserIdentifyMapper extends GenericMapper<UserIdentify, Integer> {

    @Select("SELECT t.*,u.user_name AS 'u.userName',u.mobile_phone AS 'u.mobilePhone' FROM biz_user_identify t LEFT JOIN biz_user u ON u.id = t.user_id WHERE 1=1 ${whereSql} ${sortSql} limit ${nowPage}, ${pageSize} ")
    List<UserIdentifyModel> findListBySqlJoin(Map<String, Object> params);

    @Select("SELECT count(1) FROM biz_user_bank t LEFT JOIN biz_user u ON u.id = t.user_id WHERE 1=1 ${whereSql}")
    long countBySqlJoin(Map<String, Object> params);

    /**
     * 根据用户ID 查询用户认证信息
     *
     * @param userId 用户ID
     * @return
     */
    @Select("SELECT * FROM biz_user_identify WHERE user_id = #{userId} and del_flag = 1")
    UserIdentify selectByUID(@Param(value = "userId") int userId);
}
